package com.jumi.microservice.service.excelListener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.jumi.microservice.dto.excel.ImportNoSelfResponse;
import com.jumi.microservice.service.logistics.admin.SendService;
import com.jumi.microservice.service.order.OrderServiceImpl;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wangjingdao
 */
public class ExcelListener extends AnalysisEventListener<ImportNoSelfResponse> {
    private SendService sendService;

    private Long uid;

    private String name;

    private List<ImportNoSelfResponse> partial = new ArrayList<>();

    @Override
    public void invoke(ImportNoSelfResponse data, AnalysisContext context) {
        partial.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        sendService.importNoSelfResponse(partial,uid,name);
    }

    public ExcelListener(Long uid, String name,SendService sendService) {
        this.uid = uid;
        this.name = name;
        this.sendService = sendService;
    }
}
